





import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'ListViewTestPage.dart';
import 'listData.dart';



class TextFieldPage extends StatefulWidget {
  const TextFieldPage({super.key});
  @override
  State<TextFieldPage> createState() => _TextFieldPageState();
}
class _TextFieldPageState extends State<TextFieldPage> {
  @override
  Widget build(BuildContext context) {
    final size =MediaQuery.of(context).size;

    return Scaffold(
      appBar: AppBar(
        title: const Text('1220培训任务'),
      ),
      body: Center(
          child: Padding(
            padding: const EdgeInsets.all(10),
            child: ListView(
              children: [
                const TextField(decoration: InputDecoration(hintText: "密码")),
                const SizedBox(
                  height: 20,
                ),
                const TextField(decoration: InputDecoration(hintText: "用户名")),
                const SizedBox(
                  height: 20,
                ),
                const SizedBox(height:40),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Icon(
                      Icons.grade,
                      color: Colors.grey,
                      size: 40,
                      textDirection: TextDirection.ltr,
                    ),
                    Text('row'),
                    ElevatedButton(
                      onPressed: (){

                      },
                      child: Text('Stak1'),
                    ),
                    ElevatedButton.icon(
                      icon: Icon(Icons.send),
                      label: Text("发送"),
                      onPressed:  (){
                      },
                    ),
                  ],
                ),
                Container(
                  margin: const EdgeInsets.only(left: 40, top: 40),
//设置 child 居中
                  alignment: const Alignment(0, 0),
                  height: 50,
                  width: 300,
//边框设置
                  decoration: BoxDecoration(
//背景
                    color: Colors.green,
                    //设置四周圆角 角度
                    borderRadius: const BorderRadius.all(Radius.circular(4.0)),
                    //设置四周边框
                    border: Border.all(width: 3, color: Colors.red),
                  ),
                  child: const Text("12345677890809"),
                ),
                Container(
                  padding: const EdgeInsets.all(8),
                  height: 200,
                  width: size.width,
                  child: GridView.count(
                    crossAxisCount: 2,
                    mainAxisSpacing: 4,
                    crossAxisSpacing: 4,
                     children: _buildItemView(),
                    ),
                  ),
                ElevatedButton(
                  onPressed: () {
                    //跳转路由
                    Navigator.of(context).push(
                        MaterialPageRoute(builder: (BuildContext context) {
                          return const ListViewTestPage();
                        }));
                  },
                  child: Text('进入ListView列表'),
                ),
              ],
            ),
          ),

      ),
    );



  }

  _buildItemView() {

    var tempList = listtestData.map((value) {
      return Container(
        decoration: BoxDecoration(
            border: Border.all(
                color: const Color.fromRGBO(233, 233, 233, 0.9), width: 1)),
        child: Column(
          children: <Widget>[
            Container(
             /* height: 200,
              width: 200,*/
              decoration: BoxDecoration(color: Colors.yellow),
              child: Image.network(
                  value['imageUrl']),
            ),
          ],
        ),
      );
    });
    return tempList.toList();
  }


}


